package com.tian.core.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.struts2.json.annotations.JSON;

/**
 * Group entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "group", catalog = "portalservermond")
public class Group implements java.io.Serializable {

	// Fields

	private Integer id;
	private String groupname;
	private String groupinfo;
	private Integer masterid;
	private String mastername;
	private Date createdate;
	private Set<Mastergroup> mastergroups = new HashSet<Mastergroup>(0);
	private Set<Ztreegroup> ztreegroups = new HashSet<Ztreegroup>(0);
	// Constructors

	/** default constructor */
	public Group() {
	}

	/** minimal constructor */
	public Group(String groupname, Integer masterid) {
		this.groupname = groupname;
		this.masterid = masterid;
	}

	/** full constructor */
	public Group(String groupname, String groupinfo, Integer masterid,
			String mastername, Date createdate,
			 Set<Mastergroup> mastergroups) {
		this.groupname = groupname;
		this.groupinfo = groupinfo;
		this.masterid = masterid;
		this.mastername = mastername;
		this.createdate = createdate;
		this.mastergroups = mastergroups;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "groupname", nullable = false, length = 100)
	public String getGroupname() {
		return this.groupname;
	}

	public void setGroupname(String groupname) {
		this.groupname = groupname;
	}

	@Column(name = "groupinfo", length = 100)
	public String getGroupinfo() {
		return this.groupinfo;
	}

	public void setGroupinfo(String groupinfo) {
		this.groupinfo = groupinfo;
	}

	@Column(name = "masterid")
	public Integer getMasterid() {
		return this.masterid;
	}

	public void setMasterid(Integer masterid) {
		this.masterid = masterid;
	}

	@Column(name = "mastername", length = 100)
	public String getMastername() {
		return this.mastername;
	}

	public void setMastername(String mastername) {
		this.mastername = mastername;
	}

	@Column(name = "createdate", length = 0)
	public Date getCreatedate() {
		return this.createdate;
	}

	public void setCreatedate(Date createdate) {
		this.createdate = createdate;
	}
	
	@JSON(serialize = false)
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "group")
	public Set<Mastergroup> getMastergroups() {
		return this.mastergroups;
	}

	public void setMastergroups(Set<Mastergroup> mastergroups) {
		this.mastergroups = mastergroups;
	}
	@JSON(serialize = false)
	//@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "group")
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "group")
	public Set<Ztreegroup> getZtreegroups() {
		return this.ztreegroups;
	}

	public void setZtreegroups(Set<Ztreegroup> ztreegroups) {
		this.ztreegroups = ztreegroups;
	}
}